class MySingleton {
    private static volatile MySingleton instance = null;

    public static MySingleton getInstance() {
        if(instance == null){
            synchronized (MySingleton.class){
                if(instance == null){
                    instance = new MySingleton();
                }
            }
        }
        return instance;
    }

    private MySingleton() {

    }
}
public class Demo2 {
}
